local function SpawnPaperItem(x, y, z, itemType, itemAmount)
	-- Spawn Item
	local drop = P_SpawnMobj(x, y, z, MT_FLOATINGITEM)
	drop.threshold = itemType
	drop.movecount = itemAmount
	drop.scale = $ >> 4
	drop.destscale = 3*mapobjectscale/2
	-- Spawn Backdrop
	local backdrop = P_SpawnMobjFromMobj(drop, 0, 0, 0, MT_OVERLAY)
	drop.target = backdrop
	backdrop.target = drop
	backdrop.state = S_ITEMBACKDROP
	backdrop.dispoffset = 1
	backdrop.flags2 = $|MF2_LINKDRAW
	return drop
end

local item
addHook("SpecialExecute", function(activator, args)
	for mt in mapthings.iterate
		if (mt.tid == args[1]) then
			item = SpawnPaperItem(mt.x*FRACUNIT, mt.y*FRACUNIT, mt.z*FRACUNIT, args[2], args[3])
			item.momz = mapobjectscale * (mt.args[0] + P_RandomRange(-1, 1))
			P_Thrust(item, ANG1 * (mt.angle + P_RandomRange(-1, 1)), mapobjectscale * (mt.args[1] + P_RandomRange(-1, 1)))
		end
	end
end, "FLINGPAPERITEM")
